package com.sise.controller.wechat;

import com.sise.bean.*;
import com.sise.entity.OrderRefund;
import com.sise.service.IOrderRefundService;
import com.sise.service.IOrderService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zj
 */
@RestController
@RequestMapping("/sise/wechat/order")
public class WechatOrderController {

    @Resource
    private IOrderService orderService;

    @Resource
    private IOrderRefundService orderRefundService;

    @PostMapping("/create")
    public String create(@RequestBody OrderParameterBean orderParameterBean) {
        return orderService.create(orderParameterBean);
    }

    @RequestMapping("/list")
    public CodeMsg<List<OrderListBean>> list(String openId, String orderStatus, Integer page) {
        return orderService.list(openId, orderStatus, page);
    }

    @RequestMapping("/detail")
    public OrderDetailBean detail(String openId) {
        return orderService.detail(openId);
    }

    @RequestMapping("/evaluate")
    public String evaluate(String orderId, Integer productId, Integer productScore) {
        return orderService.evaluate(orderId, productId, productScore);
    }

    @PostMapping("applyOrderRefund")
    public CodeMsg applyOrderRefund(@RequestBody OrderRefund orderRefund) {
        return orderRefundService.applyOrderRefund(orderRefund);
    }

    @PostMapping("/payOrder")
    public CodeMsg payOrder(@RequestBody OrderStatusBean orderStatusBean) {
        return orderService.payOrder(orderStatusBean);
    }

    @PostMapping("/cancelOrder")
    public CodeMsg cancelOrder(@RequestBody OrderStatusBean orderStatusBean) {
        return orderService.cancelOrder(orderStatusBean);
    }

    @PostMapping("/refundOrder")
    public CodeMsg refundOrder(@RequestBody OrderStatusBean orderStatusBean) {
        return orderService.refundOrder(orderStatusBean);
    }
}
